#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dominion.h"

void testing(struct gameState *game);
void check(char *foo, int bar, int ans);

int main(int argc, char *argv[])
{
	struct gameState *game = malloc(sizeof(struct gameState));

	testing(game);

	free(game);

	return 0;
}

void testing(struct gameState *game)
{
	struct gameState *after = malloc(sizeof(struct gameState));

	int plyr = 0;

	printf("UNIT TEST 2...........\n");

	printf("BEGIN TESTING DRAW CARD...........................\n\n");

	for(int i = 0; i < 4; i ++)
	{
		plyr = (rand() % MAX_PLAYERS) + 1;
		for(int j = 0; j < MAX_PLAYERS; j++)
		{
			game->deckCount[j] = 2;
			game->discardCount[j] = 2;
			game->handCount[j] = 5;

			// (rand() % MAX_PLAYERS)
			
			for(int p = 0; p < MAX_DECK; p++)
			{
				game->deck[j][p] = 450;
				game->discard[j][p] = 500;
			}

			for(int l = 0; l < MAX_HAND; l++)
			{
				game->hand[j][l] = 347;
			}
		}

		memcpy(after, game, sizeof(struct gameState));

		// printf("deck count: %d\n", game->deckCount[i]);

		drawCard(plyr, game);

		// printf("Player = %d\n", plyr);

		// if(plyr == 1 || plyr == 2 || plyr == 3 || plyr == 4)
		// {
		// 	printf("Test PASSED.\n");
		// }

		printf("Player = %d\n", plyr);
		printf("Deck Count: %d\n", game->deckCount[i]);
		printf("Discard Count: %d\n", game->discardCount[i]);
		printf("Hand Count: %d\n", game->handCount[i]);

		memcmp(game, after, sizeof(struct gameState));

		if(memcmp(game, after, sizeof(struct gameState)) == 0)
		{
			printf("Test FAILED.\n");
		}
		else
		{
			printf("Test PASSED.\n");
		}
	}
	free(after);

	return;
}

void check(char *foo, int ans, int expected)
{
	if(expected == ans)
	{
		printf("%s PASSED, VALUE: %d, EXPECTED: %d\n", foo, ans, expected);
	}
	else
	{
		printf("%s FAILED, VALUE: %d, EXPECTED: %d\n", foo, ans, expected);
	}
}